package com.scalar.chiptrack.commons;

import java.util.ArrayList;
import java.util.Random;

import com.scalar.chiptrack.sales.ContactPerson;

public class Address implements java.io.Serializable, Cloneable
{
    Random r                            = new Random();
    protected int addressId             = -1;
    private int vendorId                = -1;
    private int contactPersonAddressId  = -1;
    private int locAddressId            = ( r.nextInt( 10000 ) + 30001 ) * ( -1 );

    protected String address1           = null;
    protected String address2           = null;
    protected String city               = null;
    protected String state              = null;
    protected String zipCode            = null;
    protected String country            = null;
    protected String phoneNumber        = null;
    protected String faxNumber          = null;
    protected String email              = null;
    protected String remove             = null; //For removing shipping address for the customer
    protected String cellNumber         = null;
    private String active               = null;
    private String address3             = null;
    private String address4             = null;
    private String defaultAddress       = null;
    protected String contactPerson      = null;
    private String tagName              = null;
    private String vendorName           = null;
    private String receiveShipAlert     = "on";   // select by default
    protected String[] selectedLocationTypes = {};

    private ArrayList contactPersons    = new ArrayList();
    private ArrayList locationsList     = new ArrayList();
    private ContactPerson contactPersonObject = new ContactPerson();

    private String epicoreShipCode = "";
    private int gpDexRowId = -1;


    /**
     * Default Constructor
     *
     */
    public Address()
    {

    }


    /**
     * Constructor
     *
     */
    public Address( String address1, String address2, String city, String state, String country, String zipCode )
    {
        this.address1 = address1;
        this.address2 = address2;
        this.city = city;
        this.state = state;
        this.country = country;
        this.zipCode = zipCode;
    }


    /**
     * Constructor
     *
     */
    public Address( int addressId, String address1, String address2, String city, String state,
                    String zipCode, String country, String phoneNumber, String faxNumber, String email )
    {
        this.addressId = addressId;
        this.address1 = address1;
        this.address2 = address2;
        this.city = city;
        this.state = state;
        this.zipCode = zipCode;
        this.country = country;
        this.phoneNumber = phoneNumber;
        this.faxNumber = faxNumber;
        this.email = email;
    }

    public Address( int addressId, String address1, String address2, String city, String state,
                    String zipCode, String country, String phoneNumber, String faxNumber, String email, String contactPerson )
    {
        this.addressId = addressId;
        this.address1 = address1;
        this.address2 = address2;
        this.city = city;
        this.state = state;
        this.zipCode = zipCode;
        this.country = country;
        this.phoneNumber = phoneNumber;
        this.faxNumber = faxNumber;
        this.email = email;
        this.contactPerson = contactPerson;

    }

    public Address( int addressId, String address1, String address2, String city, String state,
                    String zipCode, String country, String phoneNumber, String faxNumber, String email, String contactPerson, String cellNumber )
    {
        this.addressId = addressId;
        this.address1 = address1;
        this.address2 = address2;
        this.city = city;
        this.state = state;
        this.zipCode = zipCode;
        this.country = country;
        this.phoneNumber = phoneNumber;
        this.faxNumber = faxNumber;
        this.email = email;
        this.contactPerson = contactPerson;
        this.cellNumber = cellNumber;
    }

    public Address( int addressId, String address1, String address2, String address3, String address4, String city,
                    String state, String zipCode, String country, String phoneNumber, String faxNumber, String email, String contactPerson, String cellNumber )
    {
        this.addressId = addressId;
        this.address1 = address1;
        this.address2 = address2;
        this.address3 = address3;
        this.address4 = address4;
        this.city = city;
        this.state = state;
        this.zipCode = zipCode;
        this.country = country;
        this.phoneNumber = phoneNumber;
        this.faxNumber = faxNumber;
        this.email = email;
        this.contactPerson = contactPerson;
        this.cellNumber = cellNumber;
    }


    /**
     * Get addressId
     *
     * @return addressId
     */
    public int getAddressId()
    {
        return addressId;
    }

    /**
     * Set the addressId
     *
     * @param addressId
     */
    public void setAddressId( int addressId )
    {
        this.addressId = addressId;
    }

    public int getLocAddressId()
    {
        //System.out.println("locAddressId  "+locAddressId);
        return locAddressId;
    }

    public void setLocAddressId( int locAddressId )
    {
        this.locAddressId = locAddressId;
    }

    /**
     * Get address1
     *
     * @return address1
     */
    public String getAddress1()
    {
        return address1;
    }

    /**
     * Set the address1
     *
     * @param address1
     */
    public void setAddress1( String address1 )
    {
        this.address1 = address1;
    }


    /**
     * Get address2
     *
     * @return address2
     */
    public String getAddress2()
    {
        return address2;
    }

    /**
     * Set the address2
     *
     * @param address2
     */
    public void setAddress2( String address2 )
    {
        this.address2 = address2;
    }


    /**
     * Get city
     *
     * @return city
     */
    public String getCity()
    {
        return city;
    }

    /**
     * Set the city
     *
     * @param city
     */
    public void setCity( String city )
    {
        this.city = city;
    }


    /**
     * Get state
     *
     * @return state
     */
    public String getState()
    {
        return state;
    }

    /**
     * Set the state
     *
     * @param state
     */
    public void setState( String state )
    {
        this.state = state;
    }


    /**
     * Get zipCode
     *
     * @return zipCode
     */
    public String getZipCode()
    {
        return zipCode;
    }

    /**
     * Set the zipCode
     *
     * @param zipCode
     */
    public void setZipCode( String zipCode )
    {
        this.zipCode = zipCode;
    }


    /**
     * Get country
     *
     * @return country
     */
    public String getCountry()
    {
        return country;
    }

    /**
     * Set the country
     *
     * @param country
     */
    public void setCountry( String country )
    {
        this.country = country;
    }


    /**
     * Get phoneNumber
     *
     * @return phoneNumber
     */
    public String getPhoneNumber()
    {
        if( phoneNumber == null )
            phoneNumber = "";
        return phoneNumber;
    }

    /**
     * Set the phoneNumber
     *
     * @param phoneNumber
     */
    public void setPhoneNumber( String phoneNumber )
    {
        this.phoneNumber = phoneNumber;
    }


    /**
     * Get faxNumber
     *
     * @return faxNumber
     */
    public String getFaxNumber()
    {
        if( faxNumber == null )
            faxNumber = "";
        return faxNumber;
    }

    /**
     * Set the faxNumber
     *
     * @param faxNumber
     */
    public void setFaxNumber( String faxNumber )
    {
        this.faxNumber = faxNumber;
    }

    /**
     * Get email
     *
     * @return email
     */
    public String getEmail()
    {
        if( email == null )
            email = "";
        return email;
    }

    /**
     * Set the email
     *
     * @param email
     */
    public void setEmail( String email )
    {
        this.email = email;
    }

    //Added by Sarada on 22nd Jan
    public String getContactPerson()
    {
        return contactPerson;
    }

    public void setContactPerson( String contactPerson )
    {
        this.contactPerson = contactPerson;
    }


    /**
     * Get Location Types for this Address
     *
     * @return selectedLocationTypes
     */
    public String[] getSelectedLocationTypes()
    {
        return selectedLocationTypes;
    }

    /**
     * Set the selectedLocationTypes
     *
     */
    public void setSelectedLocationTypes( String[] selectedLocationTypes )
    {
        this.selectedLocationTypes = selectedLocationTypes;
    }

    public String getRemove()
    {
        return remove;
    }

    public void setRemove( String remove )
    {
        this.remove = remove;
    }

    public String getDefaultAddress()
    {
        return defaultAddress;
    }

    public void setDefaultAddress( String defaultAddress )
    {
        this.defaultAddress = defaultAddress;
    }


    // BR, March 14, 2004
    public String getReceiveShipAlert()
    {
        return this.receiveShipAlert;
    }

    public void setReceiveShipAlert( String receiveShipAlert )
    {
        this.receiveShipAlert = receiveShipAlert;
    }

    /**
     * String representation
     */
    public String toString()
    {
        StringBuffer buf = new StringBuffer();
        buf.append( " ContactPerson = " + this.contactPerson );
        buf.append( "\nAddress1 = " + this.address1 );
        buf.append( "\nAddress2 = " + this.address2 );
        buf.append( "\nCity = " + this.city );
        buf.append( "\nState = " + this.state );
        buf.append( "\nCountry = " + this.country );
        buf.append( "\nZIP = " + this.zipCode );

        return buf.toString();
    }

    //Added by Sarada on 5th March 2004
    /**
     * @return
     */
    public String getCellNumber()
    {
        return cellNumber;
    }

    /**
     * @param cellNumber
     */
    public void setCellNumber( String cellNumber )
    {
        this.cellNumber = cellNumber;
    }

    /**
     * @return
     */
    public String getActive()
    {
        return active;
    }

    /**
     * @param string
     */
    public void setActive( String string )
    {
        active = string;
    }

    /**
     * @return
     */
    public String getAddress3()
    {
        if( address3 == null )
        {
            address3 = "";
        }
        return address3;
    }

    /**
     * @return
     */
    public String getAddress4()
    {
        if( address4 == null )
        {
            address4 = "";
        }
        return address4;
    }

    /**
     * @param string
     */
    public void setAddress3( String string )
    {
        address3 = string;
    }

    /**
     * @param string
     */
    public void setAddress4( String string )
    {
        address4 = string;
    }

    public ArrayList getContactPersons()
    {
        return contactPersons;
    }

    public void setContactPersons( ArrayList contactPersons )
    {
        this.contactPersons = contactPersons;
    }

    public ContactPerson getContactPersonObject()
    {
        return contactPersonObject;
    }

    public void setContactPersonObject( ContactPerson contactPersonObject)
    {
        this.contactPersonObject = contactPersonObject;
    }

    //Added by rohan on May13th 2004
    /**
     * Returns the epicore ship code
     *
     * @return
     */
    public String getEpicoreShipCode()
    {
        return epicoreShipCode;
    }

    /**
     * set the epicode ship code
     *
     * @param epicoreShipCode
     */
    public void setEpicoreShipCode( String epicoreShipCode )
    {
        this.epicoreShipCode = epicoreShipCode;
    }

    //End of additions by rohan on May 13th 2004

    public int getGpDexRowId()
    {
        return gpDexRowId;
    }

    public void setGpDexRowId( int gpDexRowId )
    {
        this.gpDexRowId = gpDexRowId;
    }

    //Added by Raj Kumar on May 22nd 2004
    /**
     * Cloning the object
     *
     * @return Object
     * @throws CloneNotSupportedException
     */
    public Object clone() throws CloneNotSupportedException
    {
        return super.clone();
    }
    //End of additions by Raj Kumar on May 22nd 2004


    //Added by rohan on May 22nd 2004.

    /**
     * This method will format the contents of the address object such that
     * they can be inserted in the GP database
     *
     */
    public void formatForInsertingIntoGP()
    {
        if( this.getContactPerson() == null )
        {
            this.setContactPerson( "" );
        }
        else if( this.getContactPerson().trim().length() > 31 )
        {
            this.setContactPerson( this.getContactPerson().trim().substring( 0, 30 ) );
        }

        if( this.getAddress1() == null )
        {
            this.setAddress1( "" );
        }
        else if( this.getAddress1().trim().length() > 31 )
        {
            this.setAddress1( this.getAddress1().trim().substring( 0, 30 ) );
        }

        if( this.getAddress2() == null )
        {
            this.setAddress2( "" );
        }
        else if( this.getAddress2().trim().length() > 31 )
        {
            this.setAddress2( this.getAddress2().trim().substring( 0, 30 ) );
        }

        if( this.getAddress3() == null )
        {
            this.setAddress3( "" );
        }
        else if( this.getAddress3().trim().length() > 31 )
        {
            this.setAddress3( this.getAddress3().trim().substring( 0, 30 ) );
        }

        if( this.getCountry() == null )
        {
            this.setCountry( "" );
        }
        else if( this.getCountry().trim().length() > 21 )
        {
            this.setCountry( this.getCountry().trim().substring( 0, 20 ) );
        }

        if( this.getCity() == null )
        {
            this.setCity( "" );
        }
        else if( this.getCity().trim().length() > 31 )
        {
            this.setCity( this.getCity().trim().substring( 0, 30 ) );
        }

        if( this.getState() == null )
        {
            this.setState( "" );
        }
        else if( this.getState().trim().length() > 29 )
        {
            this.setState( this.getState().trim().substring( 0, 28 ) );
        }

        if( this.getZipCode() == null )
        {
            this.setZipCode( "" );
        }
        else if( this.getZipCode().trim().length() > 11 )
        {
            this.setZipCode( this.getZipCode().trim().substring( 0, 10 ) );
        }

        if( this.getPhoneNumber() == null )
        {
            this.setPhoneNumber( "" );
        }
        else if( this.getPhoneNumber().trim().length() > 21 )
        {
            this.setPhoneNumber( this.getPhoneNumber().trim().substring( 0, 20 ) );
        }

        if( this.getFaxNumber() == null )
        {
            this.setFaxNumber( "" );
        }
        else if( this.getFaxNumber().trim().length() > 21 )
        {
            this.setFaxNumber( this.getFaxNumber().trim().substring( 0, 20 ) );
        }
    }

    //Added by rohan on June 2nd 2004.

    /**
     * This method will format the contents of the address object such that
     * they can be inserted in the CT database
     *
     */
    public void formatForInsertingIntoCT()
    {
        if( this.getAddress1() == null )
        {
            this.setAddress1( "" );
        }
        else
        {
            this.setAddress1( this.getAddress1().trim() );
        }

        if( this.getAddress1().length() > 50 )
        {
            this.setAddress1( this.getAddress1().substring( 0, 49 ) );
        }

        if( this.getAddress2() == null )
        {
            this.setAddress2( "" );
        }
        else
        {
            this.setAddress2( this.getAddress2().trim() );
        }

        if( this.getAddress2().length() > 50 )
        {
            this.setAddress2( this.getAddress2().substring( 0, 49 ) );
        }

        if( this.getAddress3() == null )
        {
            this.setAddress3( "" );
        }
        else
        {
            this.setAddress3( this.getAddress3().trim() );
        }

        if( this.getAddress3().length() > 50 )
        {
            this.setAddress3( this.getAddress3().substring( 0, 49 ) );
        }

        if( this.getAddress4() == null )
        {
            this.setAddress4( "" );
        }
        else
        {
            this.setAddress4( this.getAddress4().trim() );
        }

        if( this.getAddress4().length() > 50 )
        {
            this.setAddress4( this.getAddress4().substring( 0, 49 ) );
        }

        if( this.getCity() == null )
        {
            this.setCity( "" );
        }
        else
        {
            this.setCity( this.getCity().trim() );
        }

        if( this.getCity().length() > 50 )
        {
            this.setCity( this.getCity().substring( 0, 49 ) );
        }

        if( this.getState() == null )
        {
            this.setState( "" );
        }
        else
        {
            this.setState( this.getState().trim() );
        }

        if( this.getState().length() > 50 )
        {
            this.setState( this.getState().substring( 0, 49 ) );
        }

        if( this.getCountry() == null )
        {
            this.setCountry( "" );
        }
        else
        {
            this.setCountry( this.getCountry().trim() );
        }

        if( this.getCountry().length() > 50 )
        {
            this.setCountry( this.getCountry().substring( 0, 49 ) );
        }

        if( this.getPhoneNumber() == null )
        {
            this.setPhoneNumber( "" );
        }
        else
        {
            this.setPhoneNumber( this.getPhoneNumber().trim() );
        }

        if( this.getPhoneNumber().length() > 50 )
        {
            this.setPhoneNumber( this.getPhoneNumber().substring( 0, 49 ) );
        }

        if( this.getFaxNumber() == null )
        {
            this.setFaxNumber( "" );
        }
        else
        {
            this.setFaxNumber( this.getFaxNumber().trim() );
        }

        if( this.getFaxNumber().length() > 50 )
        {
            this.setFaxNumber( this.getFaxNumber().substring( 0, 49 ) );
        }

        if( this.getEmail() == null )
        {
            this.setEmail( "" );
        }
        else
        {
            this.setEmail( this.getEmail().trim() );
        }

        if( this.getEmail().length() > 50 )
        {
            this.setEmail( this.getEmail().substring( 0, 49 ) );
        }

        if( this.getContactPerson() == null )
        {
            this.setContactPerson( "" );
        }
        else
        {
            this.setContactPerson( this.getContactPerson().trim() );
        }

        if( this.getContactPerson().length() > 50 )
        {
            this.setContactPerson( this.getContactPerson().substring( 0, 49 ) );
        }

        if( this.getCellNumber() == null )
        {
            this.setCellNumber( "" );
        }
        else
        {
            this.setCellNumber( this.getCellNumber().trim() );
        }

        if( this.getCellNumber().length() > 50 )
        {
            this.setCellNumber( this.getCellNumber().substring( 0, 49 ) );
        }

        if( this.getEpicoreShipCode() == null )
        {
            this.setEpicoreShipCode( "" );
        }
        else
        {
            this.setEpicoreShipCode( this.getEpicoreShipCode().trim() );
        }

        if( this.getEpicoreShipCode().length() > 8 )
        {
            this.setEpicoreShipCode( this.getEpicoreShipCode().substring( 0, 7 ) );
        }

        if( this.getContactPersonObject() == null )
        {
            this.setContactPersonObject( new ContactPerson() );
        }

        this.getContactPersonObject().formatForInsertingIntoCT();
    }

    //Added by Rohan on June 2nd 2004
    /**
     * Returns if the address object is empty. Presently comparing only the
     * following fields, if required add the other fields also
     *
     * <li> Address1
     * <li> Address2
     * <li> Address3
     * <li> Address4
     * <li> City
     * <li> State
     * <li> Zipcode
     * <li> Country
     * <li> Contact Person
     * <li> Contact Person Cell Number
     *
     *
     * @return
     */
    public boolean isAddressEmpty()
    {
        //we can remove the condition for checking the cell number of the contact person as the contact person
        //details are entered only adter entering the contact person name. Please look into it.
        if( ( "".equals( this.getAddress1() ) ) && ( "".equals( this.getAddress2() ) ) &&
                ( "".equals( this.getAddress3() ) ) && ( "".equals( this.getAddress4() ) ) &&
                ( "".equals( this.getCity() ) ) && ( "".equals( this.getState() ) ) &&
                ( "".equals( this.getZipCode() ) ) && ( "".equals( this.getCountry() ) ) &&
                ( "".equals( this.getContactPerson() ) ) && ( "".equals( this.getContactPersonObject().getCellNumber() ) ) )
        {
            return true;
        }
        else
        {
            return false;
        }
    }

	/**
	 * @return
	 */
	public int getContactPersonAddressId()
	{
		return contactPersonAddressId;
	}

	/**
	 * @param i
	 */
	public void setContactPersonAddressId(int i)
	{
		contactPersonAddressId = i;
	}


    public String getTagName() {
        return tagName;
    }

    public void setTagName(String tagName) {
        this.tagName = tagName;
    }

    public String getAddressAsString( )
    {
        StringBuffer tempAddress = new StringBuffer( "" );
        String contactPerson = getContactPerson();
        String address1 = getAddress1();
        String address2 = getAddress2();
        String address3 = getAddress3();
        String address4 = getAddress4();
        String city = getCity();
        String zipCode = getZipCode();
        String state = getState();
        String country = getCountry();
        String phoneNumber = getPhoneNumber();
        String cellNumber = getCellNumber();
        String faxNumber = getFaxNumber();
        String email = getEmail();

        if( address1 != null && !( address1.trim().equals( "" ) ) )
        {
            tempAddress.append( address1 + "\n" );
        }

        if( contactPerson != null && !( contactPerson.trim().equals( "" ) ) )
        {
            tempAddress.append( contactPerson + "\n" );
        }

        if( address2 != null && !( address2.equals( "" ) ) )
        {
            tempAddress.append( address2 + "\n" );
        }
        if( address3 != null && !( address3.equals( "" ) ) )
        {
            tempAddress.append( address3 + "\n" );
        }
        if( address4 != null && !( address4.equals( "" ) ) )
        {
            tempAddress.append( address4 + "\n" );
        }
        if( city != null && !( city.equals( "" ) ) )
        {
            tempAddress.append( city + "\n" );
        }
        if( state != null && !( state.equals( "" ) ) )
        {
            tempAddress.append( state );
        }

        if( zipCode != null && !( zipCode.equals( "" ) ) )
        {
            if( state != null && !( state.equals( "" ) ) )
            {
                tempAddress.append( " - " );
            }
            tempAddress.append( zipCode );
        }

        if( country != null && !( country.equals( "" ) ) )
        {
            if( ( zipCode != null && !( zipCode.equals( "" ) ) ) || ( state != null && !( state.equals( "" ) ) ) )
            {
                tempAddress.append( ", " );
            }
            tempAddress.append( country );
        }
        tempAddress.append( ( phoneNumber != null && !( phoneNumber.equals( "" ) ) ) ? "\n\nTel:" + phoneNumber : "" );
        tempAddress.append( ( cellNumber != null && !( cellNumber.equals( "" ) ) ) ? "\nCell:" + cellNumber : "" );
        tempAddress.append( ( faxNumber != null && !( faxNumber.equals( "" ) ) ) ? "\nFax:" + faxNumber : "" );
        tempAddress.append( ( email != null && !( email.equals( "" ) ) ) ? "\nEmail: " + email : "" );
        return tempAddress.toString();
    }
    public String getVendorAddressAsString( )
    {
        StringBuffer tempAddress = new StringBuffer( "" );
        String vendorName = getVendorName();
        String contactPerson = getContactPerson();
        String address1 = getAddress1();
        String address2 = getAddress2();
        String address3 = getAddress3();
        String address4 = getAddress4();
        String city = getCity();
        String zipCode = getZipCode();
        String state = getState();
        String country = getCountry();
        String phoneNumber = getPhoneNumber();
        String cellNumber = getCellNumber();
        String faxNumber = getFaxNumber();
        String email = getEmail();

        if( vendorName != null && !( vendorName.trim().equals( "" ) ) )
        {
            tempAddress.append( vendorName + "\n" );
        }

        if( contactPerson != null && !( contactPerson.trim().equals( "" ) ) )
        {
            tempAddress.append( contactPerson + "\n" );
        }

        if( address1 != null && !( address1.trim().equals( "" ) ) )
        {
            tempAddress.append( address1 + "\n" );
        }


        if( address2 != null && !( address2.equals( "" ) ) )
        {
            tempAddress.append( address2 + "\n" );
        }
        if( address3 != null && !( address3.equals( "" ) ) )
        {
            tempAddress.append( address3 + "\n" );
        }
        if( address4 != null && !( address4.equals( "" ) ) )
        {
            tempAddress.append( address4 + "\n" );
        }
        if( city != null && !( city.equals( "" ) ) )
        {
            tempAddress.append( city + "\n" );
        }
        if( state != null && !( state.equals( "" ) ) )
        {
            tempAddress.append( state );
        }

        if( zipCode != null && !( zipCode.equals( "" ) ) )
        {
            if( state != null && !( state.equals( "" ) ) )
            {
                tempAddress.append( " - " );
            }
            tempAddress.append( zipCode );
        }

        if( country != null && !( country.equals( "" ) ) )
        {
            if( ( zipCode != null && !( zipCode.equals( "" ) ) ) || ( state != null && !( state.equals( "" ) ) ) )
            {
                tempAddress.append( ", " );
            }
            tempAddress.append( country );
        }
        tempAddress.append( ( phoneNumber != null && !( phoneNumber.equals( "" ) ) ) ? "\n\nTel:" + phoneNumber : "" );
        tempAddress.append( ( cellNumber != null && !( cellNumber.equals( "" ) ) ) ? "\nCell:" + cellNumber : "" );
        tempAddress.append( ( faxNumber != null && !( faxNumber.equals( "" ) ) ) ? "\nFax:" + faxNumber : "" );
        tempAddress.append( ( email != null && !( email.equals( "" ) ) ) ? "\nEmail :" + email : "" );
        return tempAddress.toString();
    }
    public String getAddressWithoutContactPersonAsString()
    {
        StringBuffer tempAddress =   new StringBuffer("");

        String address1 = getAddress1();
        String address2 = getAddress2();
        String address3 = getAddress3();
        String address4 = getAddress4();
        String city     = getCity();
        String zipCode  = getZipCode();
        String state    = getState();
        String country  = getCountry();

        if(address1 != null && !( "".equals ( address1.trim() ) ) )
        {
            tempAddress.append( address1 + "\n" );
        }
        if(address2!=null && !( "".equals ( address2.trim() ) ) )
        {
            tempAddress.append(address2 + "\n" );
        }
        if(address3!=null && !( "".equals ( address3.trim() ) ) )
        {
           tempAddress.append( address3 + "\n" );
        }
        if(address4!=null && !( "".equals ( address4.trim() ) ) )
        {
           tempAddress.append( address4 + "\n" );
        }
        if(city!=null && !( "".equals ( city.trim() ) ) )
        {
            tempAddress.append( city + "\n" );
        }
        if( state != null && !( state.equals( "" ) ) )
        {
            tempAddress.append( state );
        }

        if( zipCode != null && !( zipCode.equals( "" ) ) )
        {
            if( state != null && !( state.equals( "" ) ) )
            {
                tempAddress.append( " - " );
            }
            tempAddress.append( zipCode );
        }

        if( country != null && !( country.equals( "" ) ) )
        {
            if( ( zipCode != null && !( zipCode.equals( "" ) ) ) || ( state != null && !( state.equals( "" ) ) ) )
            {
                tempAddress.append( ", " );
            }
            tempAddress.append( country );
        }
        return tempAddress.toString();
    }
    public String getAddressAsHTML()
    {
        StringBuffer tempAddress = new StringBuffer( "" );
        String addrs = getAddressAsString();
        if ( addrs != null )
        {
            for( int i = 0; i < addrs.length(); i++ )
            {
                char ch = addrs.charAt( i );
                if( ch == '\n' )
                {
                    tempAddress.append( "<br>" );
                }
                else
                {
                    tempAddress.append( ch );
                }
            }
        }
        addrs = tempAddress.toString();
        return addrs;
    }


    public String getVendorName() {
        return vendorName;
    }

    public void setVendorName(String vendorName) {
        this.vendorName = vendorName;
    }


    public ArrayList getLocationsList() {
        return locationsList;
    }

    public void setLocationsList(ArrayList locationsList) {
        this.locationsList = locationsList;
    }


    public int getVendorId() {
        return vendorId;
    }

    public void setVendorId(int vendorId) {
        this.vendorId = vendorId;
    }
}